local SERVERS = {}
SERVERS.vladivostok = {"192.41.86.6:27015" , true } // adding servers is easy, take this example, vladivosttok must be lowercase 
// the first string is it's IP, the second value is a bool stating whether the server is password protected
SERVERS.toshkent = {"192.41.86.6:27017"}
SERVERS.novgorod = {"192.41.86.6:27016"}
SERVERS.stalingrad = {"192.41.86.6:27018"}


if SERVER then
	AddCSLuaFile("autorun/serverjoin.lua")

	local function ParsePlySay( ply , str )
		strl = string.lower(str)
		local server = string.match( strl , "!goto%s(%a+)") or ""
		if #server > 2 then

			local noname = false
			for k , pl in pairs(player.GetAll()) do
				local name = string.lower(pl:Nick())
				local match = string.match( name , server )
				if match then
					noname = true
				end
			end
			if !noname then
				for name , info in pairs(SERVERS) do
					local match = string.match( name , server )
					if match then
						umsg.Start("plyjoin_server" , ply )
							umsg.String( name )
							if SERVERS[name][2] then
								umsg.Bool(true)
							end
						umsg.End()
					end
				end
			end
		end
	end
	hook.Add("PlayerSay" , "Join_Other_Servers" , ParsePlySay )
else
	local function JoinServer( name , pw )
		local server = SERVERS[name]
		local ip = server[1]
		if pw then
			LocalPlayer():ConCommand("password "..pw )
		end
		LocalPlayer():ConCommand("connect "..ip )
	end

	local function GetServerJoin( um )
		local server = um:ReadString()
		local pw = um:ReadBool()
		if pw then
			Derma_StringRequest("Server Password", "    This server is passworded.\nPlease enter the password now.", "", function(text) JoinServer( server , text ) end)
		else
			JoinServer( server )
		end
	end
	usermessage.Hook("plyjoin_server" , GetServerJoin)
end